package com.wanxi.servlet.lawyer;

import com.alibaba.fastjson.JSONObject;
import com.wanxi.service.Impl.LawyerServiceImpl;
import com.wanxi.service.Impl.UserServiceImpl;
import com.wanxi.service.LawyerService;
import com.wanxi.service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Li
 * @Date 2023/5/5 14:45
 */
@WebServlet("/back/FindLawyerCount")
public class FindLawyerCountServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1.乱码问题
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        //4.调用服务逻辑层
        LawyerService lawyerService = new LawyerServiceImpl();
        int totalLawyerCount = lawyerService.totalCount();
        //数据转发给前端：IO流方式
//        数据格式使用JSON对象,引入第三方jar包，fastJson
        resp.getWriter().println(JSONObject.toJSONString(totalLawyerCount));
    }
}
